
"""
    pycoopiler - a compiler developed to PCS2056 course (Compilers) at Poli-USP
    Copyright (C) 2008 Andre Felipe Santos    
    Copyright (C) 2008 Rodrigo Rodrigues da Silva

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
"""

import unittest

from pyprosim.token import token
from pyprosim.tokenizer import tokenizer
import logging

class testtokenizer(unittest.TestCase):
    
    tkzr = None
    
    def setUp(self):
        pass
        
    def test_next_token_1(self):
        self.tkzr = tokenizer(open('cases/testprologtoken', 'r'))
        tokenlist = "ABRE_P", "NOME", "VINCULO", "NOME", "FECHA_P", "ABRE_P", "NOME", "VINCULO", "NOME", "FECHA_P", "ABRE_P", "NOME", "INF", "VINCULO", "ABRE_P", "ABRE_P", "INF", "NOME", "FECHA_P", "OP_AND", "ABRE_P", "INF", "NOME", "FECHA_P", "FECHA_P", "FECHA_P", "ABRE_P", "META", "NOME", "NOME", "FECHA_P", "EOF"
        print '\n'
        for t in tokenlist :
            logging.debug("Lido token %s", self.tkzr.current)
            self.assertEqual(self.tkzr.current.type, t)
            self.tkzr.next_token()
        
    def TestSuite():
        return unittest.makeSuite(testtokenizer)
    
    if __name__ == '__main__':
        unittest.main()
 
        
  